'use strict';
var calculate_median = function(collection){
    var arr=[];
    var a;
    for(let i=0;i<collection.length;i++){
        if(i%2!=0){
            arr.push(collection[i])
        }
    }
    var result;
    var j=arr.length/2;
    // var ab=arr.reduce( function (total,item){
    //  return total + item;}
    //  ,0);
    if(arr.length%2===0){
     //  var j=arr.length/2;
       result=(arr[j]+arr[j-1])/2
    }else{
        result=arr[parseInt(j)];
    }
    console.log(result);
    return result;
};
module.exports = calculate_median;
